#include "Name.h"
#include <stdlib.h>
#include <string.h>

Name::Name(const char *myp){
        len = strlen(myp);
        p = (char *)malloc(len +1);
        strcpy(p, myp);
}

//解决方案: 手工的编写拷贝构造函数 使用深拷贝
Name::Name(const Name &object){
        len  = object.len;
        p = (char *)malloc(len + 1);
        strcpy(p, object.p);
}

Name::~Name(){
        if(p != NULL){
                free(p);
                p = NULL;
                len = 0;
        }
}
